load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "optbuilder",
    srcs = [
        "alter_range.go",
        "alter_table.go",
        "arbiter_set.go",
        "builder.go",
        "create_function.go",
        "create_table.go",
        "create_trigger.go",
        "create_view.go",
        "delete.go",
        "distinct.go",
        "explain.go",
        "export.go",
        "fk_cascade.go",
        "groupby.go",
        "insert.go",
        "join.go",
        "limit.go",
        "locking.go",
        "misc_statements.go",
        "mutation_builder.go",
        "mutation_builder_arbiter.go",
        "mutation_builder_fk.go",
        "mutation_builder_unique.go",
        "opaque.go",
        "orderby.go",
        "partial_index.go",
        "plpgsql.go",
        "project.go",
        "routine.go",
        "scalar.go",
        "scope.go",
        "scope_column.go",
        "select.go",
        "show_trace.go",
        "sql_fn.go",
        "srfs.go",
        "statement_tree.go",
        "subquery.go",
        "union.go",
        "update.go",
        "util.go",
        "values.go",
        "window.go",
        "with.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/opt/optbuilder",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/clusterversion",
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/server/telemetry",
        "//pkg/settings",
        "//pkg/sql/catalog/catpb",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/funcinfo",
        "//pkg/sql/catalog/schemaexpr",
        "//pkg/sql/catalog/seqexpr",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/catalog/typedesc",
        "//pkg/sql/delegate",
        "//pkg/sql/lex",
        "//pkg/sql/opt",
        "//pkg/sql/opt/cat",
        "//pkg/sql/opt/memo",
        "//pkg/sql/opt/norm",
        "//pkg/sql/opt/optgen/exprgen",
        "//pkg/sql/opt/partialidx",
        "//pkg/sql/opt/props",
        "//pkg/sql/opt/props/physical",
        "//pkg/sql/parser",
        "//pkg/sql/parser/statements",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/plpgsql",
        "//pkg/sql/plpgsql/parser:plpgparser",
        "//pkg/sql/privilege",
        "//pkg/sql/sem/asof",
        "//pkg/sql/sem/builtins/builtinsregistry",
        "//pkg/sql/sem/cast",
        "//pkg/sql/sem/catconstants",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/plpgsqltree",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sem/tree/treebin",
        "//pkg/sql/sem/tree/treecmp",
        "//pkg/sql/sem/tree/treewindow",
        "//pkg/sql/sem/volatility",
        "//pkg/sql/sqlerrors",
        "//pkg/sql/sqltelemetry",
        "//pkg/sql/syntheticprivilege",
        "//pkg/sql/types",
        "//pkg/util",
        "//pkg/util/errorutil",
        "//pkg/util/errorutil/unimplemented",
        "//pkg/util/intsets",
        "//pkg/util/log",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_lib_pq//oid",
    ],
)

go_test(
    name = "optbuilder_test",
    size = "small",
    srcs = [
        "builder_test.go",
        "name_resolution_test.go",
        "statement_tree_test.go",
        "union_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":optbuilder"],
    deps = [
        "//pkg/settings/cluster",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/colinfo/colinfotestutils",
        "//pkg/sql/opt/cat",
        "//pkg/sql/opt/memo",
        "//pkg/sql/opt/testutils",
        "//pkg/sql/opt/testutils/opttester",
        "//pkg/sql/opt/testutils/testcat",
        "//pkg/sql/opt/xform",
        "//pkg/sql/parser",
        "//pkg/sql/sem/builtins",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/types",
        "//pkg/testutils/datapathutils",
        "//pkg/util/leaktest",
        "@com_github_cockroachdb_datadriven//:datadriven",
    ],
)
